<template>
  <div class="app-container" :class="{'X': isX}">
    <transition name="fade-transform" mode="out-in">
      <empty-page />
    </transition>
    <div class="tabbar-container" :class="{'X': isX}">
      <div class="tabbar-item" :class="{'active': ['Home'].includes(name)}" @click="onTabbar('Home')">
        <img src="@/assets/images/tabbar/home.png" class="icon" alt="">
        <img src="@/assets/images/tabbar/homea.png" class="icon active" alt="">
        <div>tab1</div>
      </div>
      <div class="tabbar-item" :class="{'active': ['Message'].includes(name)}" @click="onTabbar('Message')">
        <img src="@/assets/images/tabbar/msg.png" class="icon" alt="">
        <img src="@/assets/images/tabbar/msga.png" class="icon active" alt="">
        <div>tab2</div>
        <div class="msg-num">12</div>
      </div>
      <div class="tabbar-item" :class="{'active': ['My'].includes(name)}" @click="onTabbar('My')">
        <img src="@/assets/images/tabbar/my.png" class="icon" alt="">
        <img src="@/assets/images/tabbar/mya.png" class="icon active" alt="">
        <div>tab3</div>
      </div>
    </div>
  </div>
</template>

<script>
  import { isX } from '@/utils'
  import EmptyPage from './page'
  export default {
    components: { EmptyPage },
    data() {
      return {
        isX,
        name: ''
      }
    },
    watch: {
      '$route'(val) {
        this.name = val.name
      }
    },
    created() {
      this.name = this.$route.name
    },
    methods: {
      onTabbar(pagename) {
        this.$router.push({ name: pagename })
      }
    },
  }
</script>

<style lang="less" scoped>
.app-container{
  padding-bottom: .54rem;
  box-sizing: border-box;
  &.X{
    padding-bottom: .84rem;
  }
}
.tabbar-container{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: #fff;
  padding: .06rem 0;
  box-shadow: 0px -2px 10px 0px rgba(0,0,0,0.05); 
  z-index: 3;
  &.X{ // 全面屏底部适配
    padding-bottom: .30rem;
  }
  .tabbar-item{
    width: 33.33%;
    display: block;
    text-align: center;
    font-size: .10rem;
    line-height: 1;
    color: #999999;
    position: relative;
    &.active{
      color: #fa7298;
      .icon{
        display: none;
        &.active{
          display: block;
        }
      }
    }
    .icon{
      display: block;
      margin: 0 auto .06rem;
      width: .24rem;
      height: .24rem;
      &.active{
        display: none;
      }
    }
    .msg-num{
      position: absolute;
      top: -.06rem;
      left: calc(50% + .18rem);
      transform: translateX(-50%);
      line-height: .16rem;
      font-size: .12rem;
      color: #fff;
      background: linear-gradient(180deg, #FF6666 0%, #FF3636 100%);
      border-radius: .1rem;
      border: 1px solid #FFFFFF;
      padding: 0 .04rem;
    }
  }
}
</style>